﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Windows.Forms.Design;

namespace Core
{
    public class Includes :FilterablePropertyBase
    {
        public enum TypeOfInclude
        {
            [Description("Включение")]
            Including,
            [Description("Параметр")]
            Param,
            [Description("Нет")]
            None
        }


        #region Поля
        [DisplayName("Тип включения")]
        [TypeConverter(typeof(EnumTypeConverter))]
        public TypeOfInclude TypeO { get; set; }

        [DisplayName("Id")]
        [Description("Поле Id")]
        public string Id { get; set; }

        [DisplayName("Value")]
        [Description("Поле Value")]
        [Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
        [DynamicPropertyFilter("TypeO", "Param")]
        public string Value { get; set; }

        [DisplayName("Module")]
        [Description("Поле Module")]
        [DynamicPropertyFilter("TypeO", "Including")]
        public string Module { get; set; } 
        #endregion

        public Includes()
        {
            TypeO = TypeOfInclude.Param;
        }

        public Includes(TypeOfInclude typeOfInclude)
        {
            TypeO = typeOfInclude;
        }

        public override string ToString()
        {
            string result = "";
            if (TypeO == TypeOfInclude.Including)
            {
                result += "\t\t<include file=" + '"' + Value + '"' + " module=" + '"' + Module + '"' + "/>"+"\r\n";
            }
            else
            {
                result += "\t\t<param id=" + '"' + Id + '"' + " value=" + '"' + Value + '"' + "/>" + "\r\n";
            }
            return result;
        }
    }
}
